package com.fhzn.auth.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.util.List;

/**
 * @author 老顾
 * @apiNote 角色实体类
 * @since 2023/12/20
 */
@Data
@TableName("abstract_auth_role")
public class Role extends BaseEntity {

    @TableId
    private Integer id;

    private String name;

    private String code;

    private String sign;

    private Integer status;

    private String comment;

    private String appCode;

    private Integer groupId;

    private transient List<Role> canAppointRoles;

    private transient List<Integer> resourceIds;

    private transient Integer countOfAssignedUser;

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof Role)) {
            return false;
        }
        return this.getId().equals(((Role) obj).getId()) || this.getCode().equals(((Role) obj).getCode());
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 31 * result + code.hashCode();
        return result;
    }
}
